package org.okeoe.gen.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName FieldValidTypeEnum
 * @Description:
 * @Author DJ
 * @Date 2019/11/6
 * @Version V1.0
 **/
public enum FieldValidTypeEnum {
    VALID_UNIQUE_CONSTRAINTS("UNIQUE_CONSTRAINTS", "唯一"),
    VALID_EMAIL("EMAIL", "邮箱"),
    VALID_PHONE("PHONE", "手机"),
    VALID_INTEGER("INTEGER", "整数"),
    VALID_ABC("ABC", "字母"),
    VALID_ZIP_CODE("ZIP_CODE", "邮编"),
    VALID_MONEY("MONEY", "金额");

    @Getter
    private final String value;
    @Getter
    private final String desc;

    FieldValidTypeEnum(final String value, final String desc) {
        this.value = value;
        this.desc = desc;
    }
    public String getEnumName() {
        return name();
    }
    public static List toList() {
        List<Map<String,String>> list = new ArrayList();
        //  一样, 唯一它帮你做的(其实是javac帮你做的), 就是自动推导(不是"倒")尖括号里的数据类型.
        for (FieldValidTypeEnum fieldValidTypeEnum : FieldValidTypeEnum.values()) {
            Map<String, String> map = new HashMap<>();
            map.put("id", fieldValidTypeEnum.getValue());
            map.put("name", fieldValidTypeEnum.getDesc());
            list.add(map);
        }
        return list;
    }
}
